layui.use(['carousel', 'form'], function(){
	var carousel = layui.carousel,
	form = layui.form;
	 //图片轮播
	 carousel.render({
	    elem: '#carpsy',
	    width:"100%",
	    height:'300px',
	    interval: 5000
	});
	//监听开关
	form.on('switch(autoplay)', function(){
	    ins3.reload({
	      autoplay: this.checked
	    });
	});
	
	//限制字符个数
	//主页心理健康热点
	$(".psyarticlea").each(function(){
		var maxwidth=26;
		if($(this).text().length>maxwidth){
			$(this).text($(this).text().substring(0,maxwidth));
			$(this).html($(this).html()+'…');
		}
	});
	$(".aknowledge").each(function(){
		var maxwidth=36;
		if($(this).text().length>maxwidth){
			$(this).text($(this).text().substring(0,maxwidth));
			$(this).html($(this).html()+'…');
		}
	});
	
	/*点击测评，判断是否登录，是则跳转到测试界面，否则提示登录*/
	$("#gototest").click(function(){
		$.ajax({
			url: 'judgeislogin.action',  
	        type: 'get', 
	        dataType: 'json',  
	        success: function (getdata) {
	          if (getdata.code == 0) { 
	        	  window.location.href="groupPaper.jsp";
	          }else if(getdata.code == 2){
	        	  layer.confirm(getdata.msg, {
	        		  btn: ['去完善','算了'],
	        		  icon: 9
	        	  }, function(){
	        		  window.location.href = "personalMessage.jsp";
	        	  }, function(){
	        		 
	        	  });
	          }else { 
	        	  layer.msg(getdata.msg, {icon: 2});
	          }  
	        },
	        error:function(){layer.msg("请先登录！！！", {icon: 2});}
		});
	});
	
	/*$(".apsytextpaper div a").click(function(){
		var paperid=$(this).attr();
		$.ajax({
			url: 'loadpsychtest.action',  
	        type: 'post', 
	        dataType: 'json',  
	        data:{paperid:paperid},
	        success: function (getdata) {
	        },
	        error:function(){layer.alert(getdata.msg, {icon: 2});}
		});
	});*/
});